<!--图文宝修改订单-->
<div id="twbUpdateOrderPage" v-cloak>
    <el-dialog :title="title" :visible.sync="updateOrderPageVisible" :close-on-press-escape="false" :show-close="false" fullscreen>
        <div >
            <div class="col-sm-5 control-label"></div>
            <el-button type="primary" plain size="small" icon="el-icon-plus"   @click="update">保存</el-button>
            &nbsp;&nbsp;
            <el-button type="primary" plain size="small" icon="el-icon-back"  @click="reload">返回</el-button>
        </div>
        <form class="form-horizontal" style="width: auto;">
            <hr  style="width: auto;">
            <div style="margin-left: 30px">
                <el-form :inline="true" :rules="addRules" ref="addForm" :label-position="labelPosition"  :model="erpOrder" class="demo-form-inline">
                    <el-row>
                        <el-col :span="6">
                            <el-form-item label="客户名称" prop="memberName" >
                                 <template  v-if="erpOrder.deposit==0">
                                     <el-select
                                             v-model.trim="erpOrder.memberName"
                                             size="small"
                                             filterable
                                             remote
                                             reserve-keyword
                                             placeholder="请输入客户名称"
                                             :remote-method="searchMember"
                                             @focus="searchMember"
                                             @change="selectStoreMember"
                                             :loading="loading">
                                         <el-option
                                                 v-for="item in storeMemberData"
                                                 :key="item.storeMemberId"
                                                 :label="item.value"
                                                 :value="item.storeMemberId">
                                         </el-option>
                                     </el-select>
                            </template>
                                <template v-else>
                                    <el-input  v-model="erpOrder.memberName" style="width:200px" placeholder="客户名称"  size="small" disabled/>
                                </template>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="联系人" prop="shipName">
                                <el-input  v-model="erpOrder.shipName" style="width:200px" placeholder="联系人"  size="small"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="联系方式" prop="shipMobile">
                                <el-input  v-model="erpOrder.shipMobile" style="width:200px" placeholder="手机"  size="small"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="开单时间" prop="orderCreatetime">
                                <el-date-picker
                                        value-format="yyyy-MM-dd HH:mm:ss"
                                        size="small"
                                        style="width:200px"
                                        v-model="erpOrder.orderCreatetime"
                                        type="datetime"
                                        placeholder="选择日期时间"
                                >
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="6">
                            <el-form-item label="接单人">
                                <el-select v-model="erpOrder.acceptOrderUser"   size="small" filterable placeholder="请选择" >
                                    <el-option
                                            v-for="item in acceptOrderUserData"
                                            :key="item.username"
                                            :label="item.username"
                                            :value="item.username">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="收货地区" >
                                <el-cascader
                                        v-model="areaCascader"
                                        style="width: 100%"
                                        @change="handleAreaChange"
                                        size="small" placeholder="试试搜索：武汉市" :options="area" filterable >
                                </el-cascader>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="详细地址">
                                <el-input  v-model="erpOrder.shipAddr" placeholder="详细地址"  size="small"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="当前折扣率" v-show="discountRate!=0&&discountRate!=''">
                                <span >{{discountRate}}</span>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="项目名称" prop="projectName">
                                <el-input size="small" type="textarea" style="width:150%" :rows="2" placeholder="请输入内容" v-model="erpOrder.projectName"></el-input>
                            </el-form-item>
                        </el-col>
                        <!--<el-col :span="4">
                            <el-form-item label="是否收押金">
                                <el-switch
                                        v-model="erpOrder.deposit"
                                        active-color="#13ce66"
                                        inactive-color="#ff4949">
                                </el-switch>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="押金金额" v-if="erpOrder.deposit">
                                <el-input-number v-model="erpOrder.payed" size="small" controls-position="right"  :min="0"  ></el-input-number>&nbsp;元
                            </el-form-item>
                        </el-col>-->
                        <!--<el-col :span="6">
                            <el-form-item label="支付方式" v-if="erpOrder.deposit">
                                <el-select v-model="erpOrder.payment" size="small" filterable placeholder="请选择" style="width:200px">
                                    <el-option
                                            v-for="item in payTypeData"
                                            :key="item.id"
                                            :label="item.describe"
                                            :value="item.describe">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>-->
                       <!-- <el-col :span="8">
                            <el-form-item label="备注">
                                <el-input size="small" type="textarea" style="width: 400px" :rows="2" placeholder="请输入内容" v-model="erpOrder.memo"></el-input>
                            </el-form-item>
                        </el-col>-->
                    </el-row>
                </el-form>
            </div>
        </form>

        <div style="padding-bottom: 15px">
            <el-button type="primary" plain size="small" @click="addItem">新增明细</el-button>
            <!--<el-button type="primary" plain size="small" @click="delItem">删除明细</el-button>-->
        </div>
        <!--选项详情table-->
        <div >
            <el-form label-position="right" status-icon :rules="itemRules" :model="itemForm" ref="itemForm">
                <el-table
                        ref="itemTable"
                        :data="itemForm.erpOrderItemData"
                        border
                        size="small"
                        tooltip-effect="dark"
                >
                    <el-table-column
                            type="index"
                            width="50"
                            label="序号">
                    </el-table-column>
                    <el-table-column
                            prop="name"
                            label="产品名称"
                            width="300"
                    >
                        <template scope="scope" >
                            <el-form-item  :prop="'erpOrderItemData.' + scope.$index + '.name'" :rules='itemRules.name'>
                                <el-autocomplete
                                        style="width: 280px"
                                        size="small"
                                        v-model.trim="scope.row.name"
                                        :fetch-suggestions="querySearchProduct"
                                        placeholder="请输入关键字"
                                        @select="handleSelectProduct($event,scope.row)"
                                ></el-autocomplete>
                            </el-form-item>
                        </template>
                    </el-table-column>

                    <el-table-column
                            prop="addon"
                            label="规格/尺寸/材料/工艺"
                            width="300">
                        <template scope="scope" >
                            <el-form-item  :prop="'erpOrderItemData.' + scope.$index + '.addon'">
                                <el-input
                                        size="small"
                                        style="width: 280px"
                                        v-model="scope.row.addon"
                                        placeholder="请输入规格/尺寸/材料/工艺"
                                ></el-input>
                            </el-form-item>
                        </template>
                    </el-table-column>
                    <el-table-column
                            prop="unit"
                            label="单位">
                        <template scope="scope" >
                            <el-form-item  :prop="'erpOrderItemData.' + scope.$index + '.unit'">
                                <el-input v-model="scope.row.unit"     size="small" @change="handleUnit($event,scope.row)" ></el-input>
                            </el-form-item>
                        </template>
                    </el-table-column>
                    <el-table-column
                            prop="nums"
                            label="数量">
                        <template scope="scope" >
                            <el-form-item  :prop="'erpOrderItemData.' + scope.$index + '.nums'" :rules='itemRules.nums'>
                                <el-input v-model="scope.row.nums"   size="small" @change="handleNums($event,scope.row)" :min="0"></el-input>
                            </el-form-item>
                        </template>
                    </el-table-column>
                    <el-table-column
                            prop="copy"
                            label="份数">
                        <template scope="scope" >
                            <el-form-item  :prop="'erpOrderItemData.' + scope.$index + '.copy'" :rules='itemRules.copy'>
                                <el-input v-model="scope.row.copy"  size="small" @change="handlePrice($event,scope.row)" :min="0"></el-input>
                            </el-form-item>
                        </template>
                    </el-table-column>
                    <el-table-column
                            prop="price"
                            label="单价">
                        <template scope="scope" >
                            <el-form-item  :prop="'erpOrderItemData.' + scope.$index + '.price'" :rules='itemRules.price'>
                                <el-input v-model="scope.row.price"  size="small" @change="handlePrice($event,scope.row)" :min="0"></el-input>
                            </el-form-item>
                        </template>
                    </el-table-column>

                    <el-table-column
                            prop="amount"
                            label="总价">
                        <template scope="scope" >
                            <el-form-item  :prop="'erpOrderItemData.' + scope.$index + '.amount'" :rules='itemRules.amount'>
                                <el-input v-model="scope.row.amount"  size="small" @change="handleAmount($event,scope.row)"></el-input>
                            </el-form-item>
                        </template>
                    </el-table-column>
                    <el-table-column
                            prop="itemRemark"
                            label="备注"
                            width="250"
                    >
                        <template scope="scope" >
                            <el-form-item  :prop="'erpOrderItemData.' + scope.$index + '.itemRemark'">
                                <el-input
                                        style="width: 200px"
                                        type="textarea"
                                        :rows="1"
                                        placeholder="请输入备注"
                                        v-model="scope.row.itemRemark">
                                </el-input>
                            </el-form-item>
                        </template>
                    </el-table-column>
                    <el-table-column
                            fixed="right"
                            label="操作"
                            width="80">
                        <template slot-scope="scope">
                            <el-button
                                    @click.native.prevent="delItem(scope.$index, erpOrderItemData)"
                                    type="text"
                                    size="small">
                                移除
                            </el-button>
                        </template>
                    </el-table-column>

                </el-table>
            </el-form>
        </div>
    </el-dialog>
</div>
<script src="${request.contextPath}/statics/js/modules/order/updateTwbOrder.js?_${.now?long}"></script>
